//package com.main.gateway.listener;
//
//import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
//import org.springframework.cloud.gateway.route.RouteLocator;
//import org.springframework.context.ApplicationEventPublisher;
//import org.springframework.context.ApplicationListener;
//import org.springframework.stereotype.Component;
//
//@Component
//public class GatewayRefresher implements ApplicationListener<RefreshRoutesEvent> {
//
//    private final RouteLocator routeLocator;
//    private final ApplicationEventPublisher publisher;
//
//    public GatewayRefresher(RouteLocator routeLocator, ApplicationEventPublisher publisher) {
//        this.routeLocator = routeLocator;
//        this.publisher = publisher;
//    }
//
//    @Override
//    public void onApplicationEvent(RefreshRoutesEvent event) {
//        this.routeLocator.getRoutes().subscribe(route -> {
//            // 处理服务下线事件
//        });
//        // 发布事件通知Gateway刷新路由
//        this.publisher.publishEvent(new RefreshRoutesEvent(this));
//    }
//}